package com.yunshang.shoppingmall.Methods;

import com.yunshang.shoppingmall.entity.Product;
import com.yunshang.shoppingmall.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Component
public class ProductMethods {
    @Autowired
    private ProductService productService;
    private static ProductService productService1;

    private static List<String> productList = new ArrayList();

    @PostConstruct
    public void init() {
        productService1 = productService;
    }

    public static List<String> getProductList() {
        if(productList==null || productList.size()==0) {
            List<Product> productList1 = productService1.selectProductHsys();

            for(int i=0;i<productList1.size();i++)
            {
                //System.out.println(userNoList1.get(i).getUserNo());
                productList.add(productList1.get(i).getProductName());
            }
        }
        return productList;
    }
    /*
    public static UserNo getUserNo(String userNo) {
        List<UserNo> userNoList1 = userNoService1.selectUserNoList1(userNo);
        if (userNoList1 != null && userNoList1.size() == 1) {
            return userNoList1.get(0);
        }
        return null;
    }

    //插入数据
    public static int insert(UserNo userNo)
    {
        return userNoService1.insert(userNo);
    }
    */
}
